# import xlrd
# import xlutils.copy
from xlrd import open_workbook
# from xlwt import Workbook
# from xlutils.copy import copy
import openpyxl
import tkinter as tk
from tkinter import filedialog
import os
import datetime

application_window = tk.Tk()
file_types = [('excel文件', '.xls')]
xlsx_type = [('excel文件', '.xlsx')]
file_types1 = [('excel文件', '.xls'), ('excel文件', '.xlsx')]


def open_file_win(title):
    # f = askopenfilename(title='askopenfilename', initialdir="D:", filetypes=[('所有文件', '*.*'), ('Python源文件', '.py')])
    # f2 = askopenfilename(title='选择源文件', initialdir="c:", filetypes=file_types1)
    answer = filedialog.askopenfilenames(parent=application_window,
                                         initialdir=os.getcwd(),
                                         title=title,
                                         filetypes=file_types1)
    return answer


def open_one_file_win(title):
    # f = askopenfilename(title='askopenfilename', initialdir="D:", filetypes=[('所有文件', '*.*'), ('Python源文件', '.py')])
    # f2 = askopenfilename(title='选择源文件', initialdir="c:", filetypes=file_types1)
    answer = filedialog.askopenfilename(title=title,
                                        initialdir=os.getcwd(),
                                        filetypes=xlsx_type)
    return answer


def format_datetime(template):
    return datetime.datetime.now().strftime(template)
